/****************************************************
          File Name:dual_list.c
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Sat 07 Feb 2015 10:39:17 PM CST
*****************************************************/

#include "dual_list.h"
#include <stdio.h>

int main(int argc, char **argv)
{
    List *list, *tmp;
    int len;
    
    printf("enter the list's length: ");
    scanf("%d", &len);
    list = init(len);

    tmp = list;
    while(tmp->next != NULL)
    {
        printf("enter a string: ");
        scanf("%s", tmp->data);
        tmp = tmp->next;
    }

    List *node;
    node = (List *)malloc(sizeof(List));
    printf("enter a new value append to the tail: ");
    scanf("%s", node->data);
    insert(list, node);

    printf("delete a member from list's tail\n");
    if(rm(list) == ERROR) printf("rm failed\n");
    printf("now show list:\n");

    while(tmp->pre != NULL)
    {
        printf("%s\n", tmp->pre->data);
        tmp = tmp->pre;
    }

    destroy(list);

    return 0;
}
